/* cMainWindow.h
 * The main editor window.
 */
#ifndef __newmoon_cmainwindow_h
#define __newmoon_cmainwindow_h

class MainWindow;
#include <list>
#include <string>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "debugout.h"
#include "compat.h"
#include "mathx.h"
#include "uint.h"

#include "cWindow.h"
#include "cDrawBox.h"
#include "cPaletteWindow.h"
#include "cTileWindow.h"
#include "cMap16Window.h"
#include "../cLevel.h"
#include "../cROMFile.h"

class MainWindow: public Window {
	public:
		Level CurrentLevel;
		PaletteWindow *PalWin;
		TileWindow *TileWin;
		Map16Window *Map16Win;
		ROMFile ROM;
		
		MainWindow();
		MainWindow(std::string Filename);
		~MainWindow();
		bool LoadLevel(u16 Num);
	
	protected:
		DrawBox *LevelBox;
		ImgBuf *LevelBuf;
		u32 ScrollX, ScrollY; //Level scroll position, in block coords
		bool ShowBlockGrid;
		GtkLabel *StatusLabel;
		guint AnimTimer;
		u32 AnimDelay, AnimFrame; //delay in msec, current frame
		bool EnableAnimation;
	
	private:
		friend class PaletteWindow;
		friend class TileWindow;
		friend class Map16Window; //this doesn't do anything
		
		void _Create(std::string Filename);
		friend gboolean cMainWindow_AnimTimer(gpointer Win);
		friend gboolean cMainWindow_KeyPress(GtkWidget *Widget, GdkEventKey *Event, gpointer Win);
		friend gboolean cMainWindow_KeyRelease(GtkWidget *Widget, GdkEventKey *Event, gpointer Win);
		friend void cMainWindow_LevelBoxMouseButton(DrawBox* Box, GtkWidget* DrawingArea, GdkEventButton* Event, bool Press, void *Win);
		friend void cMainWindow_LevelBoxMouseMove(DrawBox* Box, GtkWidget* DrawingArea, GdkEventMotion* Event, u32 X, u32 Y, GdkModifierType State, void *Win);
		friend void cMainWindow_LevelBoxConfigureEvent(DrawBox* Box, GtkWidget* DrawingArea, GdkEventConfigure* Event, void *Win);
		friend void cMainWindow_LevelBoxExposeEvent(DrawBox* Box, GtkWidget* DrawingArea, GdkEventExpose* Event, void *Win);
		friend gboolean cMainWindow_DeleteEvent(GtkWidget *Widget, GdkEvent *Event, gpointer Win);
};
gboolean cMainWindow_AnimTimer(gpointer Win);
gboolean cMainWindow_KeyPress(GtkWidget *Widget, GdkEventKey *Event, gpointer Win);
gboolean cMainWindow_KeyRelease(GtkWidget *Widget, GdkEventKey *Event, gpointer Win);
void cMainWindow_LevelBoxMouseButton(DrawBox* Box, GtkWidget* DrawingArea, GdkEventButton* Event, bool Press, void *Win);
void cMainWindow_LevelBoxMouseMove(DrawBox* Box, GtkWidget* DrawingArea, GdkEventMotion* Event, u32 X, u32 Y, GdkModifierType State, void *Win);
void cMainWindow_LevelBoxConfigureEvent(DrawBox* Box, GtkWidget* DrawingArea, GdkEventConfigure* Event, void *Win);
void cMainWindow_LevelBoxExposeEvent(DrawBox* Box, GtkWidget* DrawingArea, GdkEventExpose* Event, void *Win);
gboolean cMainWindow_DeleteEvent(GtkWidget *Widget, GdkEvent *Event, gpointer Win);

#endif //__newmoon_cmainwindow_h
